#include<iostream>
#include<string>
#include<sstream>
#include<stdlib.h>
using namespace std;

unsigned long long  convertToInt(const string& ip) {
    int index = 3;
    unsigned long long res = 0;
    unsigned long long num = 0;
    for (int i = 0; i < ip.length(); ++i) {
        if (ip[i] == '.') {
            res += (num << (8 * index));
            --index;
            num = 0;
        }
        else {
            num = num * 10 + (ip[i] - '0');
        }
    }
    res += num;
    return res;
}

string convertToIP(const string& numStr) {
    long long num = atoll(numStr.c_str());
    string res = "";
    int index = 3;
    while (index >= 0) {
        int factor = 1 << (8 * index);
        res += to_string(num / factor) + (index == 0 ? "" : ".");
        num %= factor;
        --index;
    }
    return res;
}

int main() {
    string str1, str2;
    cin >> str1 >> str2;
    cout << convertToInt(str1) << endl;
    cout << convertToIP(str2) << endl;

}